﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" />
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="/logout">[退出]</a>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">                        
            <ul id="menu">
                <li><a href="/index" class="index_on"></a></li>
                <li><a href="/rolelist" class="role_off"></a></li>
                <li><a href="/adminList" class="admin_off"></a></li>
                <li><a href="/feelist" class="fee_off"></a></li>
                <li><a href="/accountlist" class="account_off"></a></li>
                <li><a href="/servicelist" class="service_off"></a></li>
                <li><a href="/billList" class="bill_off"></a></li>
                <li><a href="/reportList" class="report_off"></a></li>
                <li><a href="/userInfo" class="information_off"></a></li>
                <li><a href="/userModiPwd" class="password_off"></a></li>
            </ul>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">            
            <!--保存操作后的提示信息：成功或者失败-->
            <div id="save_result_info" class="save_success">保存成功！</div><!--保存失败，数据并发错误！-->
            <form action="" method="" class="main_form">
                <div class="text_info clearfix"><span>管理员账号：</span></div>
                <div class="input_info"><input type="text" readonly="readonly" class="readonly" id="adminCode"/></div>
                <div class="text_info clearfix"><span>角色：</span></div>
                <div class="input_info">
                    <input type="text" readonly="readonly" class="readonly width400" id="roleName"/>
                </div>
                <div class="text_info clearfix"><span>姓名：</span></div>
                <div class="input_info">
                    <input type="text" id="adminName"/>
                    <span class="required">*</span>
                    <div class="validate_msg_long error_msg">20长度以内的汉字、字母的组合</div>
                </div>
                <div class="text_info clearfix"><span>电话：</span></div>
                <div class="input_info">
                    <input type="text" class="width200" id="telephone"/>
                    <div class="validate_msg_medium">电话号码格式：手机或固话</div>
                </div>
                <div class="text_info clearfix"><span>Email：</span></div>
                <div class="input_info">
                    <input type="text" class="width200" id="email"/>
                    <div class="validate_msg_medium">50长度以内，符合 email 格式</div>
                </div>
                <div class="text_info clearfix"><span>创建时间：</span></div>
                <div class="input_info"><input type="text" readonly="readonly" class="readonly" id="enrolldate"/></div>
                <div class="button_info clearfix">
                    <input type="button" value="保存" class="btn_save" onclick="showResult();" />
                    <input type="button" value="取消" class="btn_save" onclick="cancel();"/>
                </div>
            </form>  
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>            
            <p>版权所有(C)云科技有限公司 </p>
        </div>
        <script src="../../js/jquery-3.2.1.js"></script>
        <script src="../../js/parseDate.js"></script>
        <script>
            $.ajax({
                url: "/selectAdminRoleByName",
                type: "post",
                success: function (data) {
                    for (var i in data){
                        var list=data[i];
                        var adminCode=list.adminCode;
                        var roleName = "";
                        for (var j in list.roleList){
                            var roleList=list.roleList[j];
                            roleName += roleList.name+" ";
                        }
                        var adminName=list.name;
                        var telephone=list.telephone;
                        var email=list.email;
                        var date=list.enrolldate;
                        var enrolldate=getLocalTime(date);
                        $("#adminCode").val(''+adminCode+'');
                        $("#roleName").val(''+roleName+'');
                        $("#adminName").val(''+adminName+'');
                        $("#telephone").val(''+telephone+'');
                        $("#email").val(''+email+'');
                        $("#enrolldate").val(''+enrolldate+'');
                    }
                }
            });
            function showResult() {
                var adminName=$("#adminName").val();
                var telephone=$("#telephone").val();
                var email=$("#email").val();
                $.ajax({
                    url:"/updateUserInfo",
                    type:"post",
                    data:{
                        name:adminName,
                        telephone:telephone,
                        email:email
                    },
                    success:function () {
                        window.location.href="/index";
                    },
                    error:function () {
                        showResultDiv(true);
                        window.setTimeout("showResultDiv(false);", 3000);
                    }
                });
            }
            function cancel() {
                if(confirm("修改尚未保存，是否取消")){
                    window.location.href="/index";
                }
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
        </script>
    </body>
</html>
